<!DOCTYPE html>
<html class="x-admin-sm">
    <head>
        {include file="public/static" /}
        <style>
            .layui-form-item .layui-input-inline{
                width: 22rem;
            }
        </style>
    </head>
    <body>
        <div class="layui-fluid">
            <div class="layui-row">
                <form class="layui-form">
                    <input type="hidden" name="id" value="%s">
                    %s
                    <div class="layui-form-item">
                        <label for="L_repass" class="layui-form-label"></label>
                        <button class="layui-btn" lay-filter="onSubmit" lay-submit="">提交</button>
                    </div>
              </form>
            </div>
        </div>
        <script>
            layui.use(['form', 'layer'], function() {
                $ = layui.jquery;
                var form = layui.form,
                layer = layui.layer;
                //自定义验证规则
                form.verify({
                    //title: function(value) {
                    //    if (value.length < 1) return '分类名称不能为空';
                    //}
                });
                /**监听提交*/
                form.on('submit(onSubmit)', function(data) {
                    var index = layer.load();
                    var data = data.field;
                    data.operate = "{$Request.param.operate}";
                    //发异步，把数据提交给php
                    $.ajax({
                        type: "post", url: "%s", data: data, dataType: 'json',
                        success:function (data) {
                            successOperate(data, index); //返回操作
                        },
                        error:function (error) {
                            layer.msg("不好意思，出现了一点问题", {icon: 5}, function () {
                                layer.close(index);
                            });
                        }
                    });
                    //必须加上return false，不然无法关闭iframe
                    return false;
                });
                /**成功返回操作*/
                function successOperate(data, index){
                    if(data.status === 1){
                        layer.msg(data.info, {icon: 6,time:1500}, function() {
                            common.closeWindowReload(); /*关闭弹出层并刷新*/
                        });
                    }else{
                        layer.msg(data.info, {icon: 5,time:1500});
                    }
                    layer.close(index);
                }
            });
        </script>
    </body>
</html>
